import request from '@/utils/request.js'
import store from '@/store'
export function authorizations (data) {
  return request({
    url: '/v1_0/authorizations',
    method: 'post',
    noToken: true,
    data
  })
}

export const smsCodes = mobile => {
  return request({
    url: `/v1_0/sms/codes/${mobile}`
  })
}

// 获取个人信息
export function userProfile () {
  return request({
    url: '/v1_0/user/profile'
  })
}

// 修改个人资料
export function userProfilePatch (data) {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data
  })
}

// 头像上传
export function userPhotoPatch (data) {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data
  })
}

// 刷新用户token
export function authorizationsPut () {
  return request({
    url: '/v1_0/authorizations',
    method: 'put',
    noToken: true,
    headers: {
      Authorization: `Bearer ${store.state.login.refresh_token}`
    }
  })
}
